package com.example.ten.controller;

import com.aaa.entity.Role;
import com.aaa.service.RoleService;
import com.aaa.util.Page;
import com.aaa.util.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author: Jyc
 * @classname: RoleController
 * @date: 2023/3/29
 * @time: 10:43
 * @description:
 */
@RestController
@RequestMapping("role")
public class RoleController extends BaseController {
    @Resource
    private RoleService roleService;

    /**
     * 查询所有启用职位(添加员工时，下拉框使用)
     * @return
     */
    @GetMapping("queryAll")
    public Result  queryAll(){
        return success(roleService.queryAll());
    }

    /**
     * 根据参数查询列表
     * @param page
     * @return
     */
    @PostMapping("queryByParam")
    public Result queryByParam(@RequestBody Page<Role> page) {
        return success(roleService.queryByParam(page));
    }


    /**
     *  根据角色ID查询该角色关联的所有权限ID集合
     * @param positionId
     * @return
     */
    @GetMapping("queryMenuIdListByRid")
    public Result queryMenuIdListByRid(Integer positionId) {
        return success(roleService.queryMenuIdListByRid(positionId));
    }

    /**
     * 添加角色权限关联
     * @param posId
     * @param menuIds
     * @return
     */
    @PostMapping("addPosAndMenu")
    public Result  addPosAndMenu(Integer posId, String menuIds){
        return success(roleService.addPosAndMenu(posId,menuIds));
    }
}
